home *** CD-ROM | disk | FTP | other *** search
- property iBookMarkSprite, iBookMarkCastList, iBookMarkList, iCurrentBookMarkStatus, iCurrentChapter, iCurrentParagraph, iVisitedMarkList, iMaxChapter, iMaxParagraphList, objMisc, iPreferenceFileName, iPreferenceFolder, iAllMarkList, iPreferenceExist, iUserName, iSavePreference
- global objfileio, galllessonlist, gBookmarkLoc, gGraphicPath, gDelimiter, onIBM, gBookmarkLoginText, gLogin
-
- on birth me
- set iBookMarkCastList to []
- mImportPict(me, "BMOFFUP.PCT")
- mImportPict(me, "BMOFFDN.PCT")
- mImportPict(me, "BMONUP.PCT")
- mImportPict(me, "BMONDN.PCT")
- set iBookMarkSprite to 23
- set the puppet of sprite iBookMarkSprite to 1
- set the castNum of sprite iBookMarkSprite to getAt(iBookMarkCastList, 1)
- set the loc of sprite iBookMarkSprite to gBookmarkLoc
- set iBookMarkList to []
- set iCurrentBookMarkStatus to 0
- set iCurrentChapter to 0
- set iCurrentParagraph to 0
- set iVisitedMarkList to []
- set iMaxChapter to count(galllessonlist)
- set iMaxParagraphList to []
- repeat with tChapter = 1 to iMaxChapter
- add(iMaxParagraphList, getAt(getAt(galllessonlist, tChapter), 2))
- end repeat
- set objMisc to birth(script "Misc_script")
- set iPreferenceFileName to EMPTY
- mGetPreferenceFile(me)
- return me
- end
-
- on mImportPict me, tPictName
- set tCast to the number of cast tPictName
- importFileInto(cast tCast, gGraphicPath & tPictName)
- set the regPoint of cast tCast to point(getAt(the rect of cast tCast, 1), getAt(the rect of cast tCast, 2))
- add(iBookMarkCastList, tCast)
- end
-
- on mGetMaxChapter me
- return iMaxChapter
- end
-
- on mGetMaxParagraph me, tChapter
- return getAt(iMaxParagraphList, tChapter)
- end
-
- on mGetStatus me, tChapter, tParagraph
- set tVisited to getAt(getAt(iVisitedMarkList, tChapter), tParagraph)
- set tMarked to getAt(getAt(iBookMarkList, tChapter), tParagraph)
- if tVisited then
- if tMarked then
- return #VISITED_MARKED
- else
- return #VISITED
- end if
- else
- if tMarked then
- return #MARKED
- else
- return #NORMAL
- end if
- end if
- end
-
- on mGetPreferenceFile me
- global gJPWinFont
- if onIBM then
- set iPreferenceFolder to mGetPreferenceFolder(objMisc) & "CDfBMark"
- else
- set iPreferenceFolder to mGetPreferenceFolder(objMisc) & "CDF BookMarks"
- end if
- set tTempItemDelimiter to the itemDelimiter
- set the itemDelimiter to "."
- if onIBM then
- set tFileName to item 1 of the movie & ".Pfs"
- else
- set tFileName to item 1 of the movie & " Prefs"
- end if
- set the itemDelimiter to tTempItemDelimiter
- set iPreferenceFileName to iPreferenceFolder & gDelimiter & tFileName
- if mFileExists(objMisc, iPreferenceFileName) then
- set iAllMarkList to value(line 2 of fileIOread(iPreferenceFileName))
- set iPreferenceExist to 1
- else
- set iAllMarkList to [:]
- set iPreferenceExist to 0
- end if
- if the romanLingo then
- if onIBM then
- set tFont to "MS Sans Serif"
- else
- set tFont to "Geneva"
- end if
- else
- if onIBM then
- set tFont to gJPWinFont
- else
- set tFont to "Osaka"
- end if
- end if
- set the text of cast "LoginQuestion" to line 1 of gBookmarkLoginText
- set the textFont of cast "LoginQuestion" to tFont
- set the text of cast "LoginUserName" to line 2 of gBookmarkLoginText
- set the textFont of cast "LoginUserName" to tFont
- set the text of cast "LoginOkButton" to line 3 of gBookmarkLoginText
- set the textFont of cast "LoginOkButton" to tFont
- set the text of cast "LoginCancelButton" to line 4 of gBookmarkLoginText
- set the textFont of cast "LoginCancelButton" to tFont
- set gLogin to 1
- end
-
- on mLogIn me, theUserName
- set iUserName to theUserName
- if iUserName = "Cancel" then
- mNewUser(me)
- set iSavePreference to 0
- else
- if iUserName = EMPTY then
- mNewUser(me)
- set iSavePreference to 0
- else
- if findPos(iAllMarkList, iUserName) then
- set tUserPreference to getaProp(iAllMarkList, iUserName)
- set iBookMarkList to the BOOKMARK of tUserPreference
- set iVisitedMarkList to the VISITED of tUserPreference
- set iSavePreference to 1
- else
- mNewUser(me)
- set iSavePreference to 1
- end if
- end if
- end if
- end
-
- on mNewUser me
- set iBookMarkList to []
- set iVisitedMarkList to []
- repeat with tChapter = 1 to iMaxChapter
- set tMaxParagraph to getAt(iMaxParagraphList, tChapter)
- set tBookmarkList to []
- set tVisitedmarkList to []
- if tMaxParagraph <> 0 then
- setAt(tBookmarkList, tMaxParagraph, 0)
- setAt(tVisitedmarkList, tMaxParagraph, 0)
- end if
- add(iBookMarkList, tBookmarkList)
- add(iVisitedMarkList, tVisitedmarkList)
- end repeat
- end
-
- on mSaveBookMarkPreference me
- if iSavePreference then
- if not mFolderExists(objMisc, iPreferenceFolder) then
- mInsureFolder(objMisc, iPreferenceFolder & gDelimiter)
- end if
- set tPreferenceList to [:]
- addProp(tPreferenceList, #BOOKMARK, iBookMarkList)
- addProp(tPreferenceList, #VISITED, iVisitedMarkList)
- addProp(tPreferenceList, #date, the date)
- addProp(tPreferenceList, #time, the time)
- setaProp(iAllMarkList, iUserName, tPreferenceList)
- set tPreferenceText to EMPTY
- put "Copyright CDF Technologies" into line 1 of tPreferenceText
- put string(iAllMarkList) into line 2 of tPreferenceText
- fileIOwrite(iPreferenceFileName, tPreferenceText)
- end if
- mClose(objMisc)
- end
-
- on mVisible me, tWhich
- set the visible of sprite iBookMarkSprite to tWhich
- end
-
- on mMouseDown me
- repeat while stillDown()
- if rollOver(iBookMarkSprite) then
- if iCurrentBookMarkStatus then
- set the castNum of sprite iBookMarkSprite to getAt(iBookMarkCastList, 4)
- else
- set the castNum of sprite iBookMarkSprite to getAt(iBookMarkCastList, 2)
- end if
- else
- if iCurrentBookMarkStatus then
- set the castNum of sprite iBookMarkSprite to getAt(iBookMarkCastList, 3)
- else
- set the castNum of sprite iBookMarkSprite to getAt(iBookMarkCastList, 1)
- end if
- end if
- updateStage()
- end repeat
- if rollOver(iBookMarkSprite) then
- if iCurrentBookMarkStatus then
- set iCurrentBookMarkStatus to 0
- setAt(getAt(iBookMarkList, iCurrentChapter), iCurrentParagraph, 0)
- set the castNum of sprite iBookMarkSprite to getAt(iBookMarkCastList, 1)
- else
- set iCurrentBookMarkStatus to 1
- setAt(getAt(iBookMarkList, iCurrentChapter), iCurrentParagraph, 1)
- set the castNum of sprite iBookMarkSprite to getAt(iBookMarkCastList, 3)
- end if
- else
- if iCurrentBookMarkStatus then
- set the castNum of sprite iBookMarkSprite to getAt(iBookMarkCastList, 3)
- else
- set the castNum of sprite iBookMarkSprite to getAt(iBookMarkCastList, 1)
- end if
- end if
- updateStage()
- end
-
- on mSetBookmarkButton me, tChapter, tParagraph
- set iCurrentChapter to tChapter
- set iCurrentParagraph to tParagraph
- set iCurrentBookMarkStatus to getAt(getAt(iBookMarkList, iCurrentChapter), iCurrentParagraph)
- if iCurrentBookMarkStatus then
- set the castNum of sprite iBookMarkSprite to getAt(iBookMarkCastList, 3)
- else
- set the castNum of sprite iBookMarkSprite to getAt(iBookMarkCastList, 1)
- end if
- end
-
- on mSetVisited me, tChapter, tParagraph
- setAt(getAt(iVisitedMarkList, tChapter), tParagraph, 1)
- end
-
- on mSetBookMark me, tChapter, tParagraph
- set tNewBookmarkStatus to not getAt(getAt(iBookMarkList, tChapter), tParagraph)
- set tVisitedmarkStatus to getAt(getAt(iVisitedMarkList, tChapter), tParagraph)
- setAt(getAt(iBookMarkList, tChapter), tParagraph, tNewBookmarkStatus)
- return list(tNewBookmarkStatus, tVisitedmarkStatus)
- end
-